package com.pattern.design.designpattern.Aidl;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;
/**
 * author:harisucici on 2018/10/30 10:56
 * email:harisucici@gmail.com
 * name:
 * todo:
 */
public class ServiceTest extends Service {


    @Override
    public void onCreate() {
        super.onCreate();
        Log.d("ServiceTest","  ----->  onCreate");
    }


    @Override
    public int onStartCommand(Intent intent,int flags, int startId) {

        Log.d("ServiceTest","  ----->  onStartCommand");

        return super.onStartCommand(intent, flags, startId);
    }


    @Override
    public void onDestroy() {
        super.onDestroy();

        Log.d("ServiceTest","  ----->  onDestroy");

    }

    @Override
    public IBinder onBind(Intent intent) {
        return new MyBinder();
    }

    //在ServiceTest中增加了一个内部类Mybind，
    // 并且在Mybind中增加一个getString方法，在方法中打印log，然后在onBind方法中返回Mybind对象。
    public class MyBinder extends Binder {
        public void getString(){
            Log.d("ServiceTest","  ----->  getString");
        }
    }
}